/**
 * 
 */
package com.toncen.samepms.common;

import java.io.File;
import java.util.List;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;

import com.toncen.samepms.interceptor.Begin;
import com.toncen.samepms.interceptor.End;
import com.toncen.samepms.interceptor.In;
import com.toncen.samepms.interceptor.Out;
import com.toncen.samepms.interceptor.Transaction;
import com.toncen.samepms.system.dao.CodeDao;
import com.toncen.samepms.system.domain.Code;
import com.toncen.samepms.util.OfficeUtils;
import com.sky.common.file.FileUtils;
import com.sky.common.ognl.OgnlUtils;
import com.sky.common.string.StringUtils;
import com.sky.dataimport.DataImportService;
import com.sky.dataimport.action.AbstractDomainFinishedAction;
import com.sky.dataimport.action.AbstractDomainInstancedAction;
import com.sky.dataimport.action.AbstractPropertyFinishedAction;
import com.sky.dataimport.action.AbstractPropertyInitializedAction;
import com.sky.dataimport.parser.AbstractDataParser;
import com.sky.dataimport.parser.DynamicRowExcelDataParser;
import com.sky.pig.PigService;

/**
 * 描述：Office相关处理Action
 * 
 * @author tch
 */
public class OfficeAction extends AbstractAction<Code> implements IDatabaseActionable<Code, CodeDao> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 17073264554908469L;
	
	private Logger logger = Logger.getLogger(OfficeAction.class.getName());

	/* =========================以下是导入导出excel配置参数================================ */
	/**
	 * 主domain的Action的类全名
	 */
	@In
	@Out
	private String actionName;

	/**
	 * 主domain在内存中的属性名
	 */
	@In
	@Out
	private String attributeName = "domain";

	/**
	 * 主domain中从表的属性名
	 */
	@In
	@Out
	private String[] manyPropertyName;

	/**
	 * 从表中主domain的属性名
	 */
	@In
	@Out
	private String[] onePropertyName;

	/**
	 * 数据对应access类全名
	 */
	@In
	@Out
	private String[] accessClassName;

	/**
	 * 
	 */
	@In
	@Out
	private Class[] accessClass;

	/**
	 * 数据对应model类全名
	 */
	@In
	@Out
	private String[] modelClassName;

	/**
	 * 
	 */
	@In
	@Out
	private Class[] modelClass;

	/**
	 * 数据解析类全名
	 */
	@In
	@Out
	private String[] parserClassName = new String[] { DynamicRowExcelDataParser.class.getName() };

	/**
	 * 
	 */
	@In
	@Out
	private Class[] parserClass;

	// 数据导入相关事件
	@In
	@Out
	private String domainInstancedActionClassName;

	@In
	@Out
	private Class domainInstancedActionClass;

	@In
	@Out
	private String domainFinishedActionClassName;

	@In
	@Out
	private Class domainFinishedActionClass;

	@In
	@Out
	private String propertyInitializedActionClassName;

	@In
	@Out
	private Class propertyInitializedActionClass;

	@In
	@Out
	private String propertyFinishedActionClassName;

	@In
	@Out
	private Class propertyFinishedActionClass;

	/**
	 * 模板路径
	 */
	@In
	@Out
	private String templatePath;

	/**
	 * 附件文件
	 */
	private File attachment;

	/**
	 * 附件名称
	 */
	private String attachmentFileName;

	/**
	 * 附件内容类型
	 */
	private String attachmentContentType;

	/* =========================以下是导出word配置参数================================ */
	/**
	 * 
	 */
	private String templateId;

	/**
	 * 
	 */
	private String dataProviderClassName;

	/**
	 * 
	 */
	private Class dataProviderClass;

	/**
	 * 
	 */
	private String wordSavePath;

	/**
	 * 
	 */
	private String wordFileName;

	/**
	 * @return the parserClassName
	 */
	public String[] getParserClassName() {
		return parserClassName;
	}

	/**
	 * @param parserClassName
	 *            the parserClassName to set
	 */
	public void setParserClassName(String[] parserClassName) {
		this.parserClassName = parserClassName;
	}

	/**
	 * @return the templatePath
	 */
	public String getTemplatePath() {
		return templatePath;
	}

	/**
	 * @param templatePath
	 *            the templatePath to set
	 */
	public void setTemplatePath(String templatePath) {
		this.templatePath = templatePath;
	}

	/**
	 * @return the attachment
	 */
	public File getAttachment() {
		return attachment;
	}

	/**
	 * @param attachment
	 *            the attachment to set
	 */
	public void setAttachment(File attachment) {
		this.attachment = attachment;
	}

	/**
	 * @return the attachmentContentType
	 */
	public String getAttachmentContentType() {
		return attachmentContentType;
	}

	/**
	 * @param attachmentContentType
	 *            the attachmentContentType to set
	 */
	public void setAttachmentContentType(String attachmentContentType) {
		this.attachmentContentType = attachmentContentType;
	}

	/**
	 * @return the attachmentFileName
	 */
	public String getAttachmentFileName() {
		return attachmentFileName;
	}

	/**
	 * @param attachmentFileName
	 *            the attachmentFileName to set
	 */
	public void setAttachmentFileName(String attachmentFileName) {
		this.attachmentFileName = attachmentFileName;
	}

	/**
	 * @return the parserClass
	 */
	public Class[] getParserClass() {
		return parserClass;
	}

	/**
	 * @throws Exception
	 */
	public OfficeAction() throws Exception {
	}

	public void delete(long domainId) throws Exception {
		throw new UnsupportedOperationException("当前接口不支持，请与系统管理员联系！");
	}

	public Code load(long domainId) throws Exception {
		throw new UnsupportedOperationException("当前接口不支持，请与系统管理员联系！");
	}

	public Code find(long domainId) throws Exception {
		throw new UnsupportedOperationException("当前接口不支持，请与系统管理员联系！");
	}

	public void save(Code domain) throws Exception {
		throw new UnsupportedOperationException("当前接口不支持，请与系统管理员联系！");
	}

	public String getActionName() {
		return actionName;
	}

	public String getAttributeName() {
		return attributeName;
	}

	public String[] getManyPropertyName() {
		return manyPropertyName;
	}

	public String[] getOnePropertyName() {
		return onePropertyName;
	}

	public void setActionName(String actionName) {
		this.actionName = actionName;
	}

	public void setAttributeName(String domainName) {
		this.attributeName = domainName;

	}

	public void setManyPropertyName(String[] manyPropertyName) {
		this.manyPropertyName = manyPropertyName;
	}

	public void setOnePropertyName(String[] onePropertyName) {
		this.onePropertyName = onePropertyName;
	}

	/**
	 * @return the accessClassName
	 */
	public String[] getAccessClassName() {
		return accessClassName;
	}

	/**
	 * @param accessClassName
	 *            the accessClassName to set
	 */
	public void setAccessClassName(String[] accessClassName) {
		this.accessClassName = accessClassName;
	}

	/**
	 * @return the modelClassName
	 */
	public String[] getModelClassName() {
		return modelClassName;
	}

	/**
	 * @param modelClassName
	 *            the modelClassName to set
	 */
	public void setModelClassName(String[] modelClassName) {
		this.modelClassName = modelClassName;
	}

	/**
	 * @return the accessClass
	 */
	public Class[] getAccessClass() {
		return accessClass;
	}

	/**
	 * @return the modelClass
	 */
	public Class[] getModelClass() {
		return modelClass;
	}

	/**
	 * @param accessClass
	 *            the accessClass to set
	 */
	public void setAccessClass(Class[] accessClass) {
		this.accessClass = accessClass;
	}

	/**
	 * @param modelClass
	 *            the modelClass to set
	 */
	public void setModelClass(Class[] modelClass) {
		this.modelClass = modelClass;
	}

	/**
	 * @param parserClass
	 *            the parserClass to set
	 */
	public void setParserClass(Class[] parserClass) {
		this.parserClass = parserClass;
	}

	/**
	 * @return the domainFinishedActionClass
	 */
	public Class getDomainFinishedActionClass() {
		return domainFinishedActionClass;
	}

	/**
	 * @param domainFinishedActionClass
	 *            the domainFinishedActionClass to set
	 */
	public void setDomainFinishedActionClass(Class domainFinishedActionClass) {
		this.domainFinishedActionClass = domainFinishedActionClass;
	}

	/**
	 * @return the domainFinishedActionClassName
	 */
	public String getDomainFinishedActionClassName() {
		return domainFinishedActionClassName;
	}

	/**
	 * @param domainFinishedActionClassName
	 *            the domainFinishedActionClassName to set
	 */
	public void setDomainFinishedActionClassName(String domainFinishedActionClassName) {
		this.domainFinishedActionClassName = domainFinishedActionClassName;
	}

	/**
	 * @return the domainInstancedActionClass
	 */
	public Class getDomainInstancedActionClass() {
		return domainInstancedActionClass;
	}

	/**
	 * @param domainInstancedActionClass
	 *            the domainInstancedActionClass to set
	 */
	public void setDomainInstancedActionClass(Class domainInstancedActionClass) {
		this.domainInstancedActionClass = domainInstancedActionClass;
	}

	/**
	 * @return the domainInstancedActionClassName
	 */
	public String getDomainInstancedActionClassName() {
		return domainInstancedActionClassName;
	}

	/**
	 * @param domainInstancedActionClassName
	 *            the domainInstancedActionClassName to set
	 */
	public void setDomainInstancedActionClassName(String domainInstancedActionClassName) {
		this.domainInstancedActionClassName = domainInstancedActionClassName;
	}

	/**
	 * @return the propertyFinishedActionClass
	 */
	public Class getPropertyFinishedActionClass() {
		return propertyFinishedActionClass;
	}

	/**
	 * @param propertyFinishedActionClass
	 *            the propertyFinishedActionClass to set
	 */
	public void setPropertyFinishedActionClass(Class propertyFinishedActionClass) {
		this.propertyFinishedActionClass = propertyFinishedActionClass;
	}

	/**
	 * @return the propertyFinishedActionClassName
	 */
	public String getPropertyFinishedActionClassName() {
		return propertyFinishedActionClassName;
	}

	/**
	 * @param propertyFinishedActionClassName
	 *            the propertyFinishedActionClassName to set
	 */
	public void setPropertyFinishedActionClassName(String propertyFinishedActionClassName) {
		this.propertyFinishedActionClassName = propertyFinishedActionClassName;
	}

	/**
	 * @return the propertyInitializedActionClass
	 */
	public Class getPropertyInitializedActionClass() {
		return propertyInitializedActionClass;
	}

	/**
	 * @param propertyInitializedActionClass
	 *            the propertyInitializedActionClass to set
	 */
	public void setPropertyInitializedActionClass(Class propertyInitializedActionClass) {
		this.propertyInitializedActionClass = propertyInitializedActionClass;
	}

	/**
	 * @return the propertyInitializedActionClassName
	 */
	public String getPropertyInitializedActionClassName() {
		return propertyInitializedActionClassName;
	}

	/**
	 * @param propertyInitializedActionClassName
	 *            the propertyInitializedActionClassName to set
	 */
	public void setPropertyInitializedActionClassName(String propertyInitializedActionClassName) {
		this.propertyInitializedActionClassName = propertyInitializedActionClassName;
	}

	public String getDataProviderClassName() {
		return dataProviderClassName;
	}

	public void setDataProviderClassName(String dataProviderClassName) {
		this.dataProviderClassName = dataProviderClassName;
	}

	public Class getDataProviderClass() {
		return dataProviderClass;
	}

	public void setDataProviderClass(Class dataProviderClass) {
		this.dataProviderClass = dataProviderClass;
	}

	public String getWordSavePath() {
		return wordSavePath;
	}

	public void setWordSavePath(String wordSavePath) {
		this.wordSavePath = wordSavePath;
	}

	public String getWordFileName() {
		return wordFileName;
	}

	public void setWordFileName(String wordFileName) {
		this.wordFileName = wordFileName;
	}

	public String getTemplateId() {
		return templateId;
	}

	public void setTemplateId(String templateId) {
		this.templateId = templateId;
	}

	public CodeDao getDao() {
		return new CodeDao();
	}

	public void setDao(CodeDao dao) {
		throw new UnsupportedOperationException("当前接口不支持，请与系统管理员联系！");
	}

	public Class getDaoClass() {
		throw new UnsupportedOperationException("当前接口不支持，请与系统管理员联系！");
	}

	/**
	 * 导入Excel
	 * 
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@Begin
	public String onDoImportExcel() throws Exception {
		if (getModelClassName() == null || getModelClassName().length == 0) {
			throw new Exception("要导入的Domain类全名必须设置，请与系统管理员联系！");
		} else {
			modelClass = new Class[getModelClassName().length];
			for (int index = 0; index < getModelClassName().length; index++) {
				try {
					modelClass[index] = Class.forName(getModelClassName()[index]);
				} catch (Exception e) {
					throw new Exception("要导入的Domain类全名【" + getModelClassName()[index] + "】不能加载，请与系统管理员联系！");
				}
				if (!AbstractDomain.class.isAssignableFrom(modelClass[index])) {
					throw new Exception("要导入的Domain类【" + getModelClassName()[index] + "】必须继承【" + AbstractDomain.class.getName() + "】，请与系统管理员联系！");
				}
			}
		}
		if (getParserClassName() == null || getParserClassName().length == 0) {
			throw new Exception("数据解析类全名必须设置，请与系统管理员联系！");
		} else {
			parserClass = new Class[getParserClassName().length];
			for (int index = 0; index < getParserClassName().length; index++) {
				try {
					parserClass[index] = Class.forName(getParserClassName()[index]);
				} catch (Exception e) {
					throw new Exception("数据解析类全名【" + getParserClassName()[index] + "】不能加载，请与系统管理员联系！");
				}
				if (!AbstractDataParser.class.isAssignableFrom(parserClass[index])) {
					throw new Exception("数据解析类【" + getParserClassName()[index] + "】必须继承【" + AbstractDataParser.class.getName() + "】，请与系统管理员联系！");
				}
			}
		}
		if (getModelClassName().length != getParserClassName().length) {
			throw new Exception("要导入的Domain类数目[" + getModelClassName().length + "]与数据解析类数目[" + getParserClassName().length + "]不匹配，请与系统管理员联系！");
		}
		if (!StringUtils.isEmpty(getDomainInstancedActionClassName())) {
			try {
				domainInstancedActionClass = Class.forName(getDomainInstancedActionClassName());
			} catch (Exception e) {
				throw new Exception("Domain实例化后监听器类全名【" + getDomainInstancedActionClassName() + "】不能加载，请与系统管理员联系！");
			}
			if (!AbstractDomainInstancedAction.class.isAssignableFrom(domainInstancedActionClass)) {
				throw new Exception("Domain实例化后监听器类【" + getDomainInstancedActionClassName() + "】必须继承【" + AbstractDomainInstancedAction.class.getName()
						+ "】，请与系统管理员联系！");
			}
		}
		if (!StringUtils.isEmpty(getDomainFinishedActionClassName())) {
			try {
				domainFinishedActionClass = Class.forName(getDomainFinishedActionClassName());
			} catch (Exception e) {
				throw new Exception("Domain实例化后监听器类全名【" + getDomainFinishedActionClassName() + "】不能加载，请与系统管理员联系！");
			}
			if (!AbstractDomainFinishedAction.class.isAssignableFrom(domainFinishedActionClass)) {
				throw new Exception("Domain实例化后监听器类【" + getDomainFinishedActionClassName() + "】必须继承【" + AbstractDomainFinishedAction.class.getName()
						+ "】，请与系统管理员联系！");
			}
		}
		if (!StringUtils.isEmpty(getPropertyInitializedActionClassName())) {
			try {
				propertyInitializedActionClass = Class.forName(getPropertyInitializedActionClassName());
			} catch (Exception e) {
				throw new Exception("Domain的属性初始化化后监听器类全名【" + getPropertyInitializedActionClassName() + "】不能加载，请与系统管理员联系！");
			}
			if (!AbstractPropertyInitializedAction.class.isAssignableFrom(propertyInitializedActionClass)) {
				throw new Exception("Domain的属性初始化化后监听器类【" + getPropertyInitializedActionClassName() + "】必须继承【"
						+ AbstractPropertyInitializedAction.class.getName() + "】，请与系统管理员联系！");
			}
		}
		if (!StringUtils.isEmpty(getPropertyFinishedActionClassName())) {
			try {
				propertyFinishedActionClass = Class.forName(getPropertyFinishedActionClassName());
			} catch (Exception e) {
				throw new Exception("Domain的属性注入后监听器类全名【" + getPropertyFinishedActionClassName() + "】不能加载，请与系统管理员联系！");
			}
			if (!AbstractPropertyFinishedAction.class.isAssignableFrom(propertyFinishedActionClass)) {
				throw new Exception("Domain的属性注入后监听器类【" + getPropertyFinishedActionClassName() + "】必须继承【" + AbstractPropertyFinishedAction.class.getName()
						+ "】，请与系统管理员联系！");
			}
		}
		int importType = getImportType();
		logger.debug("数据导入类型【" + importType + "】");
		return SUCCESS;
	}

	/**
	 * 数据导入类型:1.导入数据库；2.导入内存；
	 * 
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	private int getImportType() throws Exception {
		if (getAccessClassName() != null && getAccessClassName().length != 0) {
			accessClass = new Class[getAccessClassName().length];
			for (int index = 0; index < getAccessClassName().length; index++) {
				try {
					accessClass[index] = Class.forName(getAccessClassName()[index]);
				} catch (Exception e) {
					throw new Exception("数据对应dao类全名【" + getAccessClassName()[index] + "】不能加载，请与系统管理员联系！");
				}
				if (!AbstractDao.class.isAssignableFrom(accessClass[index])) {
					throw new Exception("数据对应dao类【" + getAccessClassName()[index] + "】必须继承【" + AbstractDao.class.getName() + "】，请与系统管理员联系！");
				}
			}
			if (getModelClassName().length != getAccessClassName().length) {
				throw new Exception("要导入的Domain类数目[" + getModelClassName().length + "]与数据对应dao类数目[" + getAccessClassName().length + "]不匹配，请与系统管理员联系！");
			}
			return 1;// 导入数据库
		} else if (!StringUtils.isEmpty(getActionName()) //
				&& !StringUtils.isEmpty(getAttributeName()) //
				&& getManyPropertyName() != null && getManyPropertyName().length != 0//
				&& getOnePropertyName() != null && getOnePropertyName().length != 0) {//
			if (getModelClassName().length != getManyPropertyName().length) {
				throw new Exception("要导入的Domain类数目[" + getModelClassName().length + "]与主domain中从表的属性名数目[" + getManyPropertyName().length + "]不匹配，请与系统管理员联系！");
			}
			if (getModelClassName().length != getOnePropertyName().length) {
				throw new Exception("要导入的Domain类数目[" + getModelClassName().length + "]与从表中主domain的属性名数目[" + getOnePropertyName().length + "]不匹配，请与系统管理员联系！");
			}
			return 2;// 导入内存
		} else {
			throw new Exception("未处理的数据导入类型，请与系统管理员联系！");
		}
	}

	/**
	 * 上传Excel
	 * 
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@End
	@Transaction
	public String onDoUploadExcel() throws Exception {
		if (getAttachment() != null && !getAttachment().exists()) {
			throw new Exception("要上传的文件【" + getAttachmentFileName() + "】不存在...");
		}
		if (!StringUtils.isEmpty(getAttachmentContentType())) {
			if (!"application/vnd.ms-excel".equalsIgnoreCase(getAttachmentContentType())) {
				throw new Exception("1.请检查要上传的文件【" + getAttachmentFileName() + "】文件类型不是【*.xls】格式!" + "2.请检查要上传的文件【" + getAttachmentFileName()
						+ "】是否处于【打开状态】,请关闭后再上传!");
			}
		} else {
			throw new Exception("1.请检查要上传的文件【" + getAttachmentFileName() + "】文件类型不是【*.xls】格式!" + "2.请检查要上传的文件【" + getAttachmentFileName()
					+ "】是否处于【打开状态】,请关闭后再上传!");
		}
		for (int index = 0; index < getModelClass().length; index++) {
			AbstractDataParser dataParser = (AbstractDataParser) getParserClass()[index].newInstance();
			AbstractDomainInstancedAction domainInstancedAction;// Domain实例化后监听器
			if (domainInstancedActionClass != null) {
				domainInstancedAction = (AbstractDomainInstancedAction) domainInstancedActionClass.newInstance();
				dataParser.setDomainInstancedAction(domainInstancedAction);
			}
			AbstractDomainFinishedAction domainFinishedAction;// Domain实例化后监听器
			if (domainFinishedActionClass != null) {
				domainFinishedAction = (AbstractDomainFinishedAction) domainFinishedActionClass.newInstance();
				dataParser.setDomainFinishedAction(domainFinishedAction);
			}
			AbstractPropertyInitializedAction propertyInitializedAction;// Domain的属性初始化化后监听器
			if (propertyInitializedActionClass != null) {
				propertyInitializedAction = (AbstractPropertyInitializedAction) propertyInitializedActionClass.newInstance();
				dataParser.setPropertyInitializedAction(propertyInitializedAction);
			}
			AbstractPropertyFinishedAction propertyFinishedAction; // Domain的属性注入后监听器
			if (propertyFinishedActionClass != null) {
				propertyFinishedAction = (AbstractPropertyFinishedAction) propertyFinishedActionClass.newInstance();
				dataParser.setPropertyFinishedAction(propertyFinishedAction);
			}
			List<AbstractDomain> list = DataImportService.parse(dataParser, getModelClass()[index], attachment);
			int importType = getImportType();
			switch (importType) {
			case 1: {// 导入数据库
				IDao dao = (IDao) getAccessClass()[index].newInstance();
				for (IDomain domain : list) {
					logger.debug("开始处理保存数据！");
					domain = domain.beforeImportSave(domain);
					dao.add(domain);
					logger.debug("数据处理完成！");
				}
				break;
			}
			case 2: {// 导入内存
				IDomain oneDomain = (IDomain) AbstractMemoryAction.getDataOne(ServletActionContext.getRequest(), getActionName(), getAttributeName(),
						getManyPropertyName()[index], getOnePropertyName()[index]);
				List<IDomain> manyDomainList = (List) AbstractMemoryAction.getDataMany(ServletActionContext.getRequest(), getActionName(), getAttributeName(),
						getManyPropertyName()[index], getOnePropertyName()[index]);
				for (IDomain domain : list) {
					domain.setId(getPrimaryID());// 设置主键
					PropertyUtils.setProperty(domain, getOnePropertyName()[index], oneDomain);// 把主表设置到从表中
					logger.debug("开始处理保存数据！");
					domain = domain.beforeImportSave(domain);
					manyDomainList.add(domain);
					logger.debug("数据处理完成！");
				}
				break;
			}
			default: {
				throw new Exception("未支持的数据导入类型[" + importType + "]，请与系统管理员联系！");
			}
			}
		}
		return SUCCESS;
	}

	/**
	 * 导出Word
	 * 
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@End
	public String onDoExportWord() throws Exception {
		if (StringUtils.isEmpty(getTemplateId())) {
			throw new Exception("导出模版必须设置，请与系统管理员联系...");
		}
		if (StringUtils.isEmpty(getDataProviderClassName())) {
			throw new Exception("导出数据提供器必须设置，请与系统管理员联系...");
		}
		if (!StringUtils.isEmpty(getDataProviderClassName())) {
			try {
				dataProviderClass = Class.forName(getDataProviderClassName());
			} catch (Exception e) {
				throw new Exception("导出数据提供器类全名【" + getDataProviderClassName() + "】不能加载，请与系统管理员联系！");
			}
			if (!AbstractComitOfficeDataProvider.class.isAssignableFrom(dataProviderClass)) {
				throw new Exception("导出数据提供器类【" + getDataProviderClassName() + "】必须继承【" + AbstractComitOfficeDataProvider.class.getName() + "】，请与系统管理员联系！");
			}
		}
		AbstractComitOfficeDataProvider dataProvider = null;
		if (dataProviderClass != null) {
			dataProvider = (AbstractComitOfficeDataProvider) dataProviderClass.newInstance();
			dataProvider.setAction(this);
			if (StringUtils.isEmpty(wordFileName)) {
				wordFileName = dataProvider.getTemplate().getName() + ".doc";
			}
			if (StringUtils.isEmpty(wordSavePath)) {
				wordSavePath = FileUtils.createTempFile("" + System.currentTimeMillis(), ".doc.temp").getAbsolutePath();
			}
			OgnlUtils.registerAlias("@@", "@" + OfficeUtils.class.getName() + "@");
			PigService.generate(wordSavePath, dataProvider);
		} else {
			throw new Exception("导出数据提供器类全名【" + getDataProviderClassName() + "】不能加载，请与系统管理员联系！");
		}
		return SUCCESS;
	}
}
